package com.shh.shojbackendgateway;

import com.alibaba.csp.sentinel.init.InitExecutor;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;


@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableDiscoveryClient
public class ShojBackendGatewayApplication {

    public static void main(String[] args) {

        SpringApplication.run(ShojBackendGatewayApplication.class, args);
        init();
    }

    /**
     * 初始化Sentinel 由于在yml中添加配置无效 所以才用手动
     */
    public static void init() {
        // 设置 Dashboard 地址
        System.setProperty(TransportConfig.CONSOLE_SERVER, "localhost:8080");
        //设置ip地址 为本机ip
        System.setProperty("csp.sentinel.heartbeat.client.ip", "192.168.1.5");
        // 初始化 Sentinel
        InitExecutor.doInit();
    }
}
